CPU 686
BITS 32

%define EOI 0x20	;End Of Interrupt
%define PIC1_CMD 0x20
%define DATA_REG 0x60

section .data

	global _kbc_scancode	;to communicate with C
	_kbc_scancode db 0
	extern _qp
	extern _queuePut
	extern _teste

	
section .bss

section .text

	global _kbc_handler
	
_kbc_handler:

	pusha	;push all registers
	
	mov ECX, 0
	
	;code
	IN AL, DATA_REG
	mov byte [_kbc_scancode], AL
	
	movzx ECX, AL
	push DWORD ECX	;loads value
	push DWORD _qp	;loads queue address
	call _queuePut
	add esp, 8
	
	mov al, EOI
	out PIC1_CMD, al
	
	popa	;pop all registers
	iretd

	global _kbc_handler_queue

_kbc_handler_queue:

	pusha
	
	;code
	call _teste

	mov al, EOI
	out PIC1_CMD, al
	
	popa
	iretd
	
END
